﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

<script type="text/javascript">
    function repeatMail() {
        var subject = $("#re_subject").html();
        var body = $("#repeat_body").val();

        var attach_id = $("#re_attach_path").val();
        var attach_name = $("#re_attach_name").val();
        $.ajax({
            type: "GET",
            url: "/Message/MailSend",
            data: { "operType": "repeat", "subject": subject, "body": body, "attachId": attach_id, "attachName": attach_name },
            success: function(data) {
                addtab('3-7', '发送邮件');
                $("#workarea-3-7").html(data);
            }
        })
    }

    function checkMail() {
        show_cover();
        $.ajax({
            type: "POST",
            url: "/Message/MailReceive",
            success: function(data) {
                addtab('3-8', '查看邮件');
                $("#workarea-3-8").html(data);
                hide_cover();
            }
        })
    }
</script>

<div>
    <%var mail = ViewData["mail"] as ValueMail.Receive.Model.MailModel; %>
    <%if (mail != null)
      { %>
    <p>
        发件人:<span><%=mail.MailHead.Address %></span></p>
    <p>
        邮箱:<span><%=mail.MailHead.Name%></span></p>
    <p>
        主题:<span id='re_subject'><%=mail.MailHead.Subject %></span></p>
    <p>
        内容:
    </p>
    <div>
        <%=mail.BodyHtml %>
    </div>
    <input type="hidden" id='repeat_body' value="<%=mail.Body %>" />
    附件:
    <%var count = mail.Attachments.Count; %>
    <%for (var index = 0; index < count; index++)
      { %>
    <p>
        <%=mail.Attachments[index].Name %>
        <a href="/Message/GetMailAttachment?index=<%=index %>&fileName=<%=mail.Attachments[index].Name %>&uid=<%=mail.MailHead.UID %>">
            下载 </a>
    </p>
    <%} %>
    <%-- <p>
        附件:<span>
            <%var count = mail.AttachName.Length; %>
            <%var attachIndex = String.Empty; %>
            <%var name = String.Empty; %>
            <%for (var index = 0; index < count; index++)
              { %>
            <%attachIndex += mail.AttachIndex[index] + ";"; %>
            <%name += mail.AttachName[index] + " "; %>
            <a href="/Message/GetAttachment?UID=<%=mail.UID %>&attachName=<%=mail.AttachName[index] %>&attachIndex=<%= mail.AttachIndex[index] %>">
                <%=mail.AttachName[index] %></a>
            <%} %>
            <%=Html.Hidden("re_attach_path", attachIndex)%>
            <%=Html.Hidden("re_attach_name",name) %>
        </span>
    </p>--%>
    <p>
        时间:<span><%=mail.MailHead.Date.ToString("yyyy-MM-dd")%></span></p>
    <%} %>
    <%--<%=Ajax.ActionLink("返回", "MailReceive", new AjaxOptions { UpdateTargetId = "workarea-3-8" }) %>--%>
    <a onclick="checkMail()">返回</a>
    <input type="button" onclick="repeatMail()" value="转发" />
</div>
